// @ts-ignore
import Mock from 'mockjs'

const user = {
    username: 'admin',
    password: '1234'
}

const users = Mock.mock({
    "list|15": [
        {
            "userid|+1": 1,
            "username": function () {
                return "admin" + Mock.Random.natural(10, 99);
            },  // rolename ,super // permission super // display super
            "role|1": [{
                id: 1,
                name: '普通管理员'
            }, {
                id: 2,
                name: '超级管理员'
            }],
            "desc": "@sentence(2)"

        }
    ]
})

/**
 *  可复用
 * */
const xueli = [{
    id: 1,
    val: '高中'
}, {
    id: 2,
    val: '大专'
}, {
    id: 3,
    val: '本科'
}
]


const depts = [
    {
        id: 1,
        "val": '人事部'
    }, {
        id: 2,
        "val": '开发部'
    }, {
        id: 3,
        "val": '财务部'
    }
]

const jobs = [
    {
        id: 1,
        val: '普通职员'
    }, {
        id: 2,
        val: '副经理'
    },
    {
        id: 3,
        val: '经理'
    }
]


const states = [
    {
        id: 1,
        val: '在职'
    }, {
        id: 2,
        val: '离职'
    }, {
        id: 3,
        val: '试用'
    }
];
const normal = Mock.mock({
    "list|5": [{
        "id|+1": 1,
        "name": "@cname",
        "empNO": function () {
            return "emp00" + this.id;
        },
        "edu|1": xueli,
        "dept|1": depts,
        "job|1": jobs,
        "state|1": states
    }]
})


const salary_normal =Mock.mock( {
    "list|5": [
        {
            "id|+1": 1,
            "name": "@cname",
            "empNO": function () {
                return "emp00" + this.id;
            },
            "edu|1": xueli,
            "dept|1": depts,
            "job|1": jobs,
            "state|1": states,
            "salary_should":"@natural(3000,10000)",
            "salary_qu":0,
            "salary_safe":"@natural(1000,2000)"

        }
    ]
})


// ajax 拦截规则
Mock.mock('http://test/login', 'get', user)
Mock.mock('http://test/sys/users', 'get', users.list)

// 员工信息管理
Mock.mock('http://test//info/nor', "get", normal.list)

//普通员工薪资
Mock.mock('http://test/salary/nor', "get", salary_normal.list)


export default {
    xueli,
    depts,
    jobs,
    states
}